package com.example.login.Mapper;

import com.example.login.Pojo.Cart;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Repository
@Mapper
public interface CartMap {
    @Select("select * from xtshop_cart where user_id=#{user_id}")
    ArrayList<Cart> getCart(int user_id);
    @Insert("INSERT INTO xtshop_cart(user_id,goods_id,sku_code,addtime,num,store_name) " +
            "VALUES(#{user_id},#{goods_id},#{sku_code},#{addtime},#{num},#{store_name})")
    void AddCart(int user_id,int goods_id,String sku_code,String addtime,int num,String store_name);
    @Select("select * from xtshop_cart where user_id=#{user_id} and goods_id=#{goods_id}")
    ArrayList<Cart> getCartById(int user_id,int goods_id);
    @Select("select num from xtshop_cart where user_id=#{user_id} and goods_id=#{goods_id}")
    int getNumById(int user_id,int goods_id);
    @Update("UPDATE xtshop_cart SET num=#{num} WHERE user_id=#{user_id} AND goods_id=#{goods_id}")
    void Update(int num,int user_id,int goods_id);
    @Delete("Delete from xtshop_cart where user_id=#{user_id} and goods_id=${goods_id};")
    void delete(int user_id,int goods_id);
}
